﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：YS_LH_JIHUAZBZXXX实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class YS_LH_JIHUAZBZXXX
    {

        private string m_str_s_laihanbh;
        /// <summary>
        /// 来函编号
        /// </summary>
        public string S_LAIHANBH { get { return m_str_s_laihanbh; } set { m_str_s_laihanbh = value; } }

        private decimal? m_dec_i_jlzt;
        /// <summary>
        /// 
        /// </summary>
        public decimal? I_JLZT { get { return m_dec_i_jlzt; } set { m_dec_i_jlzt = value; } }

        private decimal m_dec_id;
        /// <summary>
        /// 
        /// </summary>
        public decimal ID { get { return m_dec_id; } set { m_dec_id = value; } }

        private decimal? m_dec_i_feiyongbh;
        /// <summary>
        /// 费用编号
        /// </summary>
        public decimal? I_FEIYONGBH { get { return m_dec_i_feiyongbh; } set { m_dec_i_feiyongbh = value; } }

        private decimal? m_dec_i_ym;
        /// <summary>
        /// 水量年月
        /// </summary>
        public decimal? I_YM { get { return m_dec_i_ym; } set { m_dec_i_ym = value; } }

        private decimal? m_dec_n_yingshouje;
        /// <summary>
        /// 应收金额
        /// </summary>
        public decimal? N_YINGSHOUJE { get { return m_dec_n_yingshouje; } set { m_dec_n_yingshouje = value; } }

        private decimal? m_dec_n_shishouje;
        /// <summary>
        /// 实收金额
        /// </summary>
        public decimal? N_SHISHOUJE { get { return m_dec_n_shishouje; } set { m_dec_n_shishouje = value; } }

        private decimal? m_dec_n_hexiaoje;
        /// <summary>
        /// 核销金额
        /// </summary>
        public decimal? N_HEXIAOJE { get { return m_dec_n_hexiaoje; } set { m_dec_n_hexiaoje = value; } }

        private decimal? m_dec_n_jiajiaje;
        /// <summary>
        /// 加价金额
        /// </summary>
        public decimal? N_JIAJIAJE { get { return m_dec_n_jiajiaje; } set { m_dec_n_jiajiaje = value; } }

        private decimal? m_dec_n_qianfeije;
        /// <summary>
        /// 欠费金额
        /// </summary>
        public decimal? N_QIANFEIJE { get { return m_dec_n_qianfeije; } set { m_dec_n_qianfeije = value; } }

        private string m_str_s_yonghuh;
        /// <summary>
        /// 用户号
        /// </summary>
        public string S_YONGHUH { get { return m_str_s_yonghuh; } set { m_str_s_yonghuh = value; } }
        public YS_LH_JIHUAZBZXXX()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace BLL.Access
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class YS_LH_JIHUAZBZXXXProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public YS_LH_JIHUAZBZXXXProcess() { conn = Platform.Configuration.ConfigHelper.PlatformConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据YS_LH_JIHUAZBZXXX实体添加或者修改YS_LH_JIHUAZBZXXX信息
        /// </summary>
        public bool InsertOrUpdate(YS_LH_JIHUAZBZXXX YS_LH_JIHUAZBZXXX, OracleTransaction Transaction)
        {
            if (YS_LH_JIHUAZBZXXX.ID == 0)
            {
                InsertYS_LH_JIHUAZBZXXX(YS_LH_JIHUAZBZXXX, Transaction);
            }
            else
            {
                UpdateYS_LH_JIHUAZBZXXX(YS_LH_JIHUAZBZXXX, Transaction);
            }
            return YS_LH_JIHUAZBZXXX.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据YS_LH_JIHUAZBZXXX实体添加或修改YS_LH_JIHUAZBZXXX信息
        /// </summary>
        public bool InsertOrUpdate(YS_LH_JIHUAZBZXXX YS_LH_JIHUAZBZXXX)
        {
            return InsertOrUpdate(YS_LH_JIHUAZBZXXX, null);
        }



        /// <summary>
        /// 根据YS_LH_JIHUAZBZXXX主键删除YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteYS_LH_JIHUAZBZXXX(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelYS_LH_JIHUAZBZXXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据YS_LH_JIHUAZBZXXX主键删除YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteYS_LH_JIHUAZBZXXX(decimal ID)
        {
            return DeleteYS_LH_JIHUAZBZXXX(ID, null);
        }

        /// <summary>
        /// 根据条件删除YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteYS_LH_JIHUAZBZXXXesDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelYS_LH_JIHUAZBZXXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteYS_LH_JIHUAZBZXXXesDynamic(string WhereClause)
        {
            return DeleteYS_LH_JIHUAZBZXXXesDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据YS_LH_JIHUAZBZXXX主键选择YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_LH_JIHUAZBZXXX信息</returns>
        public YS_LH_JIHUAZBZXXX SelectYS_LH_JIHUAZBZXXX(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelYS_LH_JIHUAZBZXXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                YS_LH_JIHUAZBZXXX YS_LH_JIHUAZBZXXX = PopulateYS_LH_JIHUAZBZXXX(rd);
                rd.Close();
                return YS_LH_JIHUAZBZXXX;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据YS_LH_JIHUAZBZXXX主键选择YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <returns>YS_LH_JIHUAZBZXXX信息</returns>
        public YS_LH_JIHUAZBZXXX SelectYS_LH_JIHUAZBZXXX(decimal ID)
        {
            return SelectYS_LH_JIHUAZBZXXX(ID, null);
        }

        /// <summary>
        /// 选择所有YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有YS_LH_JIHUAZBZXXX信息</returns>
        public DataTable SelectYS_LH_JIHUAZBZXXXesAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelYS_LH_JIHUAZBZXXXesAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <returns>所有YS_LH_JIHUAZBZXXX信息</returns>
        public DataTable SelectYS_LH_JIHUAZBZXXXesAll()
        {
            return SelectYS_LH_JIHUAZBZXXXesAll(null);
        }

        /// <summary>
        /// 根据条件选择YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_LH_JIHUAZBZXXX信息</returns>
        public DataTable SelectYS_LH_JIHUAZBZXXXesDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelYS_LH_JIHUAZBZXXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>YS_LH_JIHUAZBZXXX信息</returns>
        public DataTable SelectYS_LH_JIHUAZBZXXXesDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectYS_LH_JIHUAZBZXXXesDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_LH_JIHUAZBZXXX信息</returns>
        public DataTable SelectYS_LH_JIHUAZBZXXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelYS_LH_JIHUAZBZXXXesDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择YS_LH_JIHUAZBZXXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>YS_LH_JIHUAZBZXXX信息</returns>
        public DataTable SelectYS_LH_JIHUAZBZXXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectYS_LH_JIHUAZBZXXXesDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新YS_LH_JIHUAZBZXXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateYS_LH_JIHUAZBZXXXesDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdYS_LH_JIHUAZBZXXXDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新YS_LH_JIHUAZBZXXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateYS_LH_JIHUAZBZXXXesDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateYS_LH_JIHUAZBZXXXesDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertYS_LH_JIHUAZBZXXX(YS_LH_JIHUAZBZXXX YS_LH_JIHUAZBZXXX, OracleTransaction Transaction)
        {
            string spName = "CS_InsYS_LH_JIHUAZBZXXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = YS_LH_JIHUAZBZXXX.S_LAIHANBH;
            storedParams[1].Value = YS_LH_JIHUAZBZXXX.I_JLZT;
            storedParams[2].Value = YS_LH_JIHUAZBZXXX.I_FEIYONGBH;
            storedParams[3].Value = YS_LH_JIHUAZBZXXX.I_YM;
            storedParams[4].Value = YS_LH_JIHUAZBZXXX.N_YINGSHOUJE;
            storedParams[5].Value = YS_LH_JIHUAZBZXXX.N_SHISHOUJE;
            storedParams[6].Value = YS_LH_JIHUAZBZXXX.N_HEXIAOJE;
            storedParams[7].Value = YS_LH_JIHUAZBZXXX.N_JIAJIAJE;
            storedParams[8].Value = YS_LH_JIHUAZBZXXX.N_QIANFEIJE;
            storedParams[9].Value = YS_LH_JIHUAZBZXXX.S_YONGHUH;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            YS_LH_JIHUAZBZXXX.ID = Convert.ToInt32(storedParams[10].Value);
            return result;
        }
        private bool UpdateYS_LH_JIHUAZBZXXX(YS_LH_JIHUAZBZXXX YS_LH_JIHUAZBZXXX, OracleTransaction Transaction)
        {
            string spName = "CS_UpdYS_LH_JIHUAZBZXXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = YS_LH_JIHUAZBZXXX.S_LAIHANBH;
            storedParams[1].Value = YS_LH_JIHUAZBZXXX.I_JLZT;
            storedParams[2].Value = YS_LH_JIHUAZBZXXX.I_FEIYONGBH;
            storedParams[3].Value = YS_LH_JIHUAZBZXXX.I_YM;
            storedParams[4].Value = YS_LH_JIHUAZBZXXX.N_YINGSHOUJE;
            storedParams[5].Value = YS_LH_JIHUAZBZXXX.N_SHISHOUJE;
            storedParams[6].Value = YS_LH_JIHUAZBZXXX.N_HEXIAOJE;
            storedParams[7].Value = YS_LH_JIHUAZBZXXX.N_JIAJIAJE;
            storedParams[8].Value = YS_LH_JIHUAZBZXXX.N_QIANFEIJE;
            storedParams[9].Value = YS_LH_JIHUAZBZXXX.S_YONGHUH;
            storedParams[10].Value = YS_LH_JIHUAZBZXXX.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private YS_LH_JIHUAZBZXXX PopulateYS_LH_JIHUAZBZXXX(IDataReader dr)
        {
            YS_LH_JIHUAZBZXXX YS_LH_JIHUAZBZXXX = new YS_LH_JIHUAZBZXXX();
            YS_LH_JIHUAZBZXXX.S_LAIHANBH = dr["S_LAIHANBH"] == DBNull.Value ? null : (string)dr["S_LAIHANBH"];
            YS_LH_JIHUAZBZXXX.I_JLZT = dr["I_JLZT"] == DBNull.Value ? null : (decimal?)dr["I_JLZT"];
            YS_LH_JIHUAZBZXXX.ID = dr["ID"] == DBNull.Value ? (decimal)0 : (decimal)dr["ID"];
            YS_LH_JIHUAZBZXXX.I_FEIYONGBH = dr["I_FEIYONGBH"] == DBNull.Value ? null : (decimal?)dr["I_FEIYONGBH"];
            YS_LH_JIHUAZBZXXX.I_YM = dr["I_YM"] == DBNull.Value ? null : (decimal?)dr["I_YM"];
            YS_LH_JIHUAZBZXXX.N_YINGSHOUJE = dr["N_YINGSHOUJE"] == DBNull.Value ? null : (decimal?)dr["N_YINGSHOUJE"];
            YS_LH_JIHUAZBZXXX.N_SHISHOUJE = dr["N_SHISHOUJE"] == DBNull.Value ? null : (decimal?)dr["N_SHISHOUJE"];
            YS_LH_JIHUAZBZXXX.N_HEXIAOJE = dr["N_HEXIAOJE"] == DBNull.Value ? null : (decimal?)dr["N_HEXIAOJE"];
            YS_LH_JIHUAZBZXXX.N_JIAJIAJE = dr["N_JIAJIAJE"] == DBNull.Value ? null : (decimal?)dr["N_JIAJIAJE"];
            YS_LH_JIHUAZBZXXX.N_QIANFEIJE = dr["N_QIANFEIJE"] == DBNull.Value ? null : (decimal?)dr["N_QIANFEIJE"];
            YS_LH_JIHUAZBZXXX.S_YONGHUH = dr["S_YONGHUH"] == DBNull.Value ? null : (string)dr["S_YONGHUH"];
            return YS_LH_JIHUAZBZXXX;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion